package cn.toutatis.common.controllerDepand;

import cn.toutatis.common.config.TimeConstant;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Toutatis_Gc
 * 每张建立表必须字段,不得缺省
 */
public class EntityBasicAttribute<O extends Model<?>> extends Model<O> {

    /**
     * 预留
     */
    @TableField("reservedId")
    public Integer reservedId;

    /**
     * 预留
     */
    @TableField("reservedMsg")
    public String reservedMsg;

    /**
     * 创建日期
     */
    @JsonIgnore
    @TableField("createTime")
    public Date createTime;

    @JsonIgnore
    @TableField("lastUpdateTime")
    public Date lastUpdateTime;

    /**
     * 数据状态
     */
    @TableField("`status`")
    public String status;

    public Integer getReservedId() {
        return reservedId;
    }

    public void setReservedId(Integer reservedId) {
        this.reservedId = reservedId;
    }

    public String getReservedMsg() {
        return reservedMsg;
    }

    public void setReservedMsg(String reservedMsg) {
        this.reservedMsg = reservedMsg;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime == null ? new Date() : createTime;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getCreateTimeStr() {
        return createTime == null ? "" : new SimpleDateFormat(TimeConstant.INSTANCE.DATE_FORMAT_REGEX).format(createTime);
    }

    public long getCreateTimeMs() {
        return createTime == null ? 0L : createTime.getTime();
    }

    public Date getLastUpdateTime() {
        return lastUpdateTime;
    }

    public void setLastUpdateTime(Date lastUpdateTime) {
        this.lastUpdateTime = lastUpdateTime == null ? new Date() : lastUpdateTime;
    }

    public String getLastUpdateTimeStr() {
        return lastUpdateTime == null ? "" : new SimpleDateFormat(TimeConstant.INSTANCE.DATE_FORMAT_REGEX).format(lastUpdateTime);
    }

    public long getLastUpdateTimeMs() {
        return lastUpdateTime == null ? 0L : lastUpdateTime.getTime();
    }
}
